@extends('Admin.layout')
@section('content')

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
               广告管理
                <small>广告编辑</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
                <li><a href="#">广告管理</a></li>
                <li class="active">广告编辑</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">快速编辑广告</h3>
                        </div><!-- /.box-header -->


                        <!-- form start -->
                        <form role="form" method="post" action="{{ url('/admin/ad/update')  }}"  enctype="multipart/form-data"  >
                         {{ csrf_field() }}
                            <div class="box-body">

                                @if (session('info'))
                                <div class="alert alert-danger alert-dismissable">
                                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                                <h4><i class="icon fa fa-ban"></i> 提示!</h4> 
                                    <h4> {{ session('info') }}  </h4>
                                </div>
                                @endif


                                <!-- 错误提示 -->
                                @if (count($errors) > 0)
                                <div class="alert alert-danger alert-dismissable">
                                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                                <h4><i class="icon fa fa-ban"></i> 警告!</h4> 
                                    <ol>
                                    @foreach ($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                    @endforeach
                                    </ol>
                                </div>
                                @endif<!-- 错误提示 -->
                                

                                <div class="form-group">
                                    <label for="name">广告商户</label>
                                    <input type="hidden" name='id' value="{{ $data->id }}">
                                    <select class="form-control select2" name="name" style="width: 100%;">
                                    
                                    @foreach($compname as $v)

                                    <option value="{{ $v->id}}"
                                    @if($data->name==$v->id)
                                    selected='true'
                                    @endif
                                    >{{ $v->compname }}</option>
                                    @endforeach
                                </select> 
                                </div>

                                 <div class="form-group">
                                <label for="position">广告位置</label>
                                <select class="form-control select2" name="position" style="width: 100%;">
                                
                                    @foreach($position as $v)
                                    <option 

                                    @if($data->position==$v->id)
                                    selected='true '
                                    @endif
                                    value="{{ $v->id}}"
                                   
                                    >{{ $v->position }}</option>
                                    @endforeach
                                </select> 
                                </div><!-- /.form-group -->
                               <!-- 上传图片 -->
                                <div class="form-group">
                                    <label for="img">图片</label>
                                    <img style="width:100px" src="{{ url('./ads/') }}/{{ $data->img }}" alt="">
                                    <input type="file" id="exampleInputFile" name='img' id='img'>
                                    <p class="help-block">请点击更换图片</p>
                                </div>

                                <div class="form-group">
                                <!-- 状态 -->
                                <label for="status">状态</label>
                                <select class="form-control select2" id='status' name="status" style="width: 100%;">

                                    <option value='0'
                                    @if($data->status==0)
                                    selected="true";
                                    @endif
                                    >关闭</option>
                                    <option value='1'
                                    @if($data->status==1)
                                    selected="true";
                                    @endif

                                    >启用</option>
                                </select>
                                </div><!-- /.form-group -->

                   


                              
                                
                                
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">编辑</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>

                        </form>
                    </div><!-- /.box -->


                    <!-- Input addon -->
                

                </div><!--/.col (left) -->
                <!-- right column -->
             
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->





@endsection